<?php
/**
 * User admin page. Used in admin action in UserController.
 *
 * @package   views
 * @subpackage user
 * @since     1.0
 * @filesource
 */

if ($organization) {
	$this->breadcrumbs=array(
		'Organization'=>array('organization/admin'),
		$organization->name=>array('organization/update','id'=>$organization->id),
	);
}
$this->breadcrumbs[]='Users';

$this->menu=array(
	array('label'=>'Create User', 'url'=>array('create'), 'linkOptions'=>array('target'=>$organization?'_blank':''))
);

?>

<h1>Manage Users <?php echo $organization?'of '.$organization->name:'';?></h1>

<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'user-grid',
	'dataProvider'=>$model->search($organization?$organization->id:null),
	'filter'=>$model,
	'columns'=>array(
		'username',
		array(
			'name'=>'title',
			'filter'=>DataUtil::getTitles(),
		),
		'firstName',
		'lastName',
		array(
			'name'=>'globalCreate',
			'type'=>'boolean',
			'filter'=>DataUtil::getOptionYesNo(),
		),
		array(
			'name'=>'globalView',
			'type'=>'boolean',
			'filter'=>DataUtil::getOptionYesNo(),
		),
		array(
			'name'=>'globalDownload',
			'type'=>'boolean',
			'filter'=>DataUtil::getOptionYesNo(),
		),
		array(
			'name'=>'globalUpdate',
			'type'=>'boolean',
			'filter'=>DataUtil::getOptionYesNo(),
		),
		array(
			'name'=>'globalDelete',
			'type'=>'boolean',
			'filter'=>DataUtil::getOptionYesNo(),
		),
		array(
			'header'=>'Manage Access',
			'type'=>'raw',
			'value'=>'CHtml::link($data->organizationAccessesCount,array("organizationAccess/admin","userId"=>$data->id))',
		),
		array(
			'class'=>'CButtonColumn',
			'template'=>'{update} {delete}',
			'updateButtonUrl'=>'Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey))',
			'updateButtonOptions'=>array('class'=>'update','target'=>($organization?'_blank':'')),
			'deleteConfirmation'=>"Deleting this user will also deleting all associated Organization Accesses records
				\n and set user field null in all associated Patient Signal records. 
				\n Are you sure you want to delete this user?",
		),
	),
)); ?>
